﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TagPropagator
{
    public class PurgeAgent : IPurgeAgent
    {
        public void Purge(Graph graph, double similarityLimit)
        {
            List<Node> nodes = graph.Nodes;
            
            foreach (var n in graph.Nodes)
            {
                int [] keys = new int[n.Neighbours.Count];
                n.Neighbours.Keys.CopyTo(keys, 0);
                foreach(var id in keys) 
                {
                    if (n.Neighbours[id] < similarityLimit)
                    {
                        n.Neighbours.Remove(id);
                        nodes[id].Neighbours.Remove(n.ID);
                    }
                }
            }
        }
    }
}
